//Made by kippieeej aka Bassoe

importPackage(net.sf.odinms.net.channel);
importPackage(net.sf.odinms.client);
importPackage(net.sf.odinms.tools);

var status = 0;
var chicken = 0;
var famecost = 100000;
var defamecost = 200000;
var killcost = 500000;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendSimple("Hello #h #, Welcome to #rChickenMS!#k\r\nWhat do you want to do?\r\n#L1##bFame Someone (" + famecost + " Mesos)#k#l\r\n#L2##bDefame Someone (" + defamecost + " Mesos)#k#l\r\n#L3##rKill someone (" + killcost + ") Mesos#k#l");
		} else if (status == 1) {
			if (selection == 1) {
				cm.sendGetText("Who do you want to fame?");
				chicken = 1;							
			} else if (selection == 2) {
				cm.sendGetText("Who do you want to defame?");
				chicken = 2;
			} else if (selection == 3) {
				cm.sendGetText("Who do you want to kill?");
				chicken = 3;
			}
		} else if (status == 2) {
			if (chicken == 1) {
				if (cm.getMeso() >= famecost) {
					victim = cm.getPlayer().getClient().getChannelServer().getPlayerStorage().getCharacterByName(cm.getText());
					if (victim != null) {
						victim.gainFame(1);
						victim.updateSingleStat(MapleStat.FAME, victim.getFame());
						victim.getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You have gained 1 fame."));
						cm.gainMeso(-famecost);
					} else
						cm.sendOk("I can't find him/her\r\nare you sure you spelled the name correctly?");
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #bMesos#k\r\nDon't scam me or I will use this on you! #s9001001#");
					cm.dispose();
				}
			} else if (chicken == 2) {
				if (cm.getMeso() >= defamecost) {
					victim = cm.getPlayer().getClient().getChannelServer().getPlayerStorage().getCharacterByName(cm.getText());
					if (victim != null) {
						victim.gainFame(-1);
						victim.updateSingleStat(MapleStat.FAME, victim.getFame());
						victim.getClient().getSession().write(MaplePacketCreator.serverNotice(6, "You have lost 1 fame"));
						cm.gainMeso(-defamecost);
					} else
						cm.sendOk("I can't find him/her\r\nare you sure you spelled the name correctly?");
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #bMesos#k\r\nDon't scam me or I will use this on you! #s9001001#");
					cm.dispose();
				}
			} else if (chicken == 3) {
				if (cm.getMeso() >= killcost) {
					cm.gainMeso(-killcost);
                                	victim = cm.getPlayer().getClient().getChannelServer().getPlayerStorage().getCharacterByName(cm.getText());
					victim.getClient().getSession().write(MaplePacketCreator.serverNotice(6, "Hey, " + cm.getPlayer().getName() + " has killed you, I think he hates you!"));
					cm.spawnMob(100100, 100, 100, 1, 5, 0, 0, 5, 341, 34);
    					victim.setHp(0);
    					victim.setMp(0);
    					victim.updateSingleStat(MapleStat.HP, 0);
    					victim.updateSingleStat(MapleStat.MP, 0);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #bMesos#k\r\nDon't scam me or I will use this on you! #s9001001#");
					cm.dispose();
				}
			}
		} 
	}
}